Export Excel to SQL table
Hi,
We have mutiple tables in an work sheet as mentioned below
Teamcount: [Table1 in worksheet1]
Teammembername | Status | TeamMembertype | Department
Team skill: [Table2 in worksheet1]
TeammemberName | Primarary Skill | Secondary Skill | Prim Exp | Second Exp
Now we want to pick data from the worksheet and should be able to create two tables in SQL database. No chance of manual moving the data and breaking it into two worksheet. Its a feed from other system.
Regards,
Navin
Navin.D http://navind.spaces.live.com/
November 9th, 2010 8:06am
Have you tried creating SSIS package???
As alternative
SELECT * INTO newTable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\MyExcel.xls";
User ID=Admin;Password=;Extended properties=Excel 8.0')...Book1$Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
November 9th, 2010 8:27am
No luck it picks up only first table info and created all fields of first table and second table data showed as rows under firstable including field names.
same case with SSIS package, I used import/export wizard.
Navin.D http://navind.spaces.live.com/
November 9th, 2010 8:41am
Are you able to get the behaviour you require with the import/export wizard? You can certainly use Excel as the source and then send results from different sheets to different tables. If you then choose to save the package you can view it in BIDS and see
how an SSIS package may look.
Essentially you will have a single Excel Source Connection and OLEDB Destination Connection. Then you can have 2 data flow tasks, one for each sheet to each table.every day is a school day
Free Windows Admin Tool Kit Click here and download it now
November 9th, 2010 9:03am
Are you able to name the range of cell in the source spreadsheet. If you do this they will appear as different tables when you connect to the spreadsheet via SSIS.
November 9th, 2010 9:50am
Is this a one time load or r u going to truncate tables in sql and load them again every time u get the new data?. but i can suggest u if u r truncating the tables when new data comes in. Here's something u can do, take excel source connect it to Execute
sql task which would truncate tables in sql each time new data comes in then connect it to data conversion task and make sure the data types and length of the datatypes of the fields in sql tables. data types should be string and length should be same as u
have in sql tables and connect it to OLEDB destination. if u r not truncating the tables then no need of execute sql task.
Free Windows Admin Tool Kit Click here and download it now
November 9th, 2010 10:15am
Named range has done the trick for us:
Create linked server to excel as below
EXEC sp_addlinkedserver 'ExcelSource',
'Jet 4.0',
'Microsoft.Jet.OLEDB.4.0',
'C:\Documents and Settings\kamdnukl\Desktop\15.xls',
NULL,
'Excel 5.0'
In excel first table from row a2:a15 select all the cells and in the name box give name as Team, it creates named range for those cells. Save
Execute following query to select data for table1 :
SELECT
*
FROM ExcelSource...Team
In excel second table from row a20:a50 select all the cells and in the name box give name as Teamer, it creates named range for those cells. Save and close the excel.
Execute following query to select data for table2 :
SELECT
*
FROM ExcelSource...Teamer
SSIS Import export wizard work as well.
Only problem i get data, but not the column headings.
Navin.D http://navind.spaces.live.com/
November 10th, 2010 1:25am